package org.medbeans.modules.patients;

import org.openide.TopManager;
//import org.openide.DialogDescriptor;
import org.openide.NotifyDescriptor;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.CallableSystemAction;

import com.surveycom.sdj.Named;

/** Action that can always be invoked and work procedurally.
 *
 * @author  Werner Keil
 */
public class MyAction extends CallableSystemAction implements Named {

    public void performAction () {
        // do what you want
/*        
        SearchPanel dp = new SearchPanel(); // create new DialogPanel 
        DialogDescriptor dd = new DialogDescriptor (dp, NbBundle.getMessage(MyAction.class, "LBL_ActionTitle")); //create new DialogDescriptor 
        dp.requestFocus(); // set focus to component which was specified in MyPanel's requestFocus() method 
        TopManager.getDefault ().createDialog (dd).show (); //show dialog 
        
        //what to do when dialog was closed 
        if (dd.getValue () == DialogDescriptor.OK_OPTION) { 
        //ok button was pressed 
            TopManager.getDefault ().notify (new NotifyDescriptor.Message("You entered "+ 
            String.valueOf(dp.getNameField().getSelectedItem())));
        } 
         else{ 
         //cancel button was pressed 
              TopManager.getDefault ().notify (new NotifyDescriptor.Message("No Name Was Entered! "));
        }           
 */
        SearchPanel searchPanel = new SearchPanel();
        
        searchPanel.showDialog();

        if(searchPanel.getReturnStatus() == SearchPanel.RET_OK) {

            //ok button was pressed 
            TopManager.getDefault ().notify (new NotifyDescriptor.Message("You entered "+ 
            String.valueOf(searchPanel.getNameField().getSelectedItem())));
            
            /*ResultModel resultModel = performSearch(nodes, searchPanel, clonedSearchTypeList);

            ResultViewTopComponent resultWindow = (ResultViewTopComponent)resultViewSRef.get();
            
            if(resultWindow == null) {// create a new result window
                resultWindow = new ResultViewTopComponent(resultModel);
                resultViewSRef = new SoftReference(resultWindow);
            } else { // reuse the result window, only set the new result model
                resultWindow.setModel(resultModel);
            }

            resultWindow.open();
            resultWindow.requestFocus();
             */
        }        
    }

    public String getName () {
        return NbBundle.getMessage(MyAction.class, "LBL_Action");
    }

    protected String iconResource () {
        //return "/org/medbeans/resources/MyActionIcon.gif";
        return "res/PatientSearch.gif";
    }

    public HelpCtx getHelpCtx () {
        return HelpCtx.DEFAULT_HELP;
        // If you will provide context help then use:
        // return new HelpCtx (MyAction.class);
    }

    /** Perform extra initialization of this action's singleton.
     * PLEASE do not use constructors for this purpose!
    protected void initialize () {
	super.initialize ();
     * putProperty (Action.SHORT_DESCRIPTION, NbBundle.getMessage (MyAction.class, "HINT_Action"));
    }
    */

}
